<template>
  <div id="user-info">
    <main-content :edit-component-name="editComponentName" :name="name" :query-condition="queryCondition"
                  :table-head="tableHead" :buttons="buttons"></main-content>
  </div>
</template>

<script>
  import {mapState} from 'vuex'
  import mainContent from '../../../common/main-content'
  export default {
    computed: {
      ...mapState({
        buttons: state => state.manager.buttons
      })
    },
    name: "user-info",
    components: {
      mainContent,
    },
    mounted() {
      this.initQueryCondition()
    },
    methods: {
      initQueryCondition(){
        this.$set(this.queryCondition[2],'url',this.buttons.children[0].children[1].target)
        this.$set(this.queryCondition[2],'permission',this.buttons.children[0].children[1].id)
        let condition = {
          name: '归属公司',
          key: 'companyId',
          type: 'select'
        }
        this.common.request({
          url: this.buttons.children[0].children[0].target,
          param: {
            parentId: '0',
          },
          loading:false,
          permission:this.buttons.children[0].children[0].id,
          success: res => {
            if (res.code == 1) {
              this.$set(condition, 'options', this.common.isEmpty(res.data.rows) ? [] : res.data.rows)
              this.$set(this.queryCondition, this.queryCondition.length, condition)
            }
          }
        })
      }
    },
    data() {
      return {
        name:'用户',
        editComponentName: 'user-edit',
        queryCondition:[{
          key:'name',
          name:'姓名',
          type:'input'
        },{
          key:'code',
          name:'用户编号',
          type:'input'
        },{
          key:'officeId',
          name:'归属部门',
          type:'union-select',
          initValue:'0',
        }],
        tableHead:[{
          key:'loginName',
          name:'登录名',
        },{
          key:'name',
          name:'真实姓名',
        },{
          key:'code',
          name:'用户编号',
        },{
          key:'company',
          name:'归属公司',
        },{
          key:'office',
          name:'归属部门',
        },{
          key:'role',
          name:'角色名',
        },{
          key:'phone',
          name:'办公电话',
        },{
          key:'mobile',
          name:'手机号码'
        }],
      }
    },
    watch: {},


  }
</script>

<style scoped>

</style>
